/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package assignment2.data;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author tuan
 */
@Stateless
public class UsersFacade extends AbstractFacade<Users> {
    @PersistenceContext(unitName = "Assignment2-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public UsersFacade() {
        super(Users.class);
    }

    public boolean checkLogin(String username, String password) {
        Query query = em.createNamedQuery("Users.checkLogin");
        query.setParameter("userName",username );
         query.setParameter("password", password);
        if(query.getResultList() != null && query.getResultList().size()>0){
        return true;
        }
        return false;
    }
    
}

